package org.edu.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

@Entity
@Proxy(lazy = false)
@Table(name = "STUDENTLESSON", catalog = "SCHOOL")
public class StudentLesson implements Serializable {

	private static final long serialVersionUID = 4502790793084429178L;

	private Long student_lesson_id;
	private Student student;
	private TeacherLesson teacherLesson;
	private Notesl notesl;
	private Boolean choose_lesson;
	private Boolean status_lesson;

	@Id
	@GeneratedValue
	@Column(name = "STUDENT_LESSON_ID")
	public Long getStudent_lesson_id() {
		return student_lesson_id;
	}

	public void setStudent_lesson_id(Long student_lesson_id) {
		this.student_lesson_id = student_lesson_id;
	}

	@ManyToOne
	@JoinColumn(name = "STUDENT_ID")
	public Student getStudent() {
		return student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	@ManyToOne
	@JoinColumn(name = "TEACHER_LESSON_ID")
	public TeacherLesson getTeacherLesson() {
		return teacherLesson;
	}

	public void setTeacherLesson(TeacherLesson teacherLesson) {
		this.teacherLesson = teacherLesson;
	}

	@OneToOne(mappedBy = "studentLesson", cascade = CascadeType.ALL)
	public Notesl getNotesl() {
		return notesl;
	}

	public void setNotesl(Notesl notesl) {
		this.notesl = notesl;
	}
	
	@Column(name = "CHOOSE_LESSON")
	public Boolean getChoose_lesson() {
		return choose_lesson;
	}

	public void setChoose_lesson(Boolean choose_lesson) {
		this.choose_lesson = choose_lesson;
	}
	
	@Column(name = "STATUS_LESSON")
	public Boolean getStatus_lesson() {
		return status_lesson;
	}

	public void setStatus_lesson(Boolean status_lesson) {
		this.status_lesson = status_lesson;
	}

	public StudentLesson() {
		super();
		// TODO Auto-generated constructor stub
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((choose_lesson == null) ? 0 : choose_lesson.hashCode());
		result = prime * result
				+ ((status_lesson == null) ? 0 : status_lesson.hashCode());
		result = prime
				* result
				+ ((student_lesson_id == null) ? 0 : student_lesson_id
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		StudentLesson other = (StudentLesson) obj;
		if (choose_lesson == null) {
			if (other.choose_lesson != null)
				return false;
		} else if (!choose_lesson.equals(other.choose_lesson))
			return false;
		if (status_lesson == null) {
			if (other.status_lesson != null)
				return false;
		} else if (!status_lesson.equals(other.status_lesson))
			return false;
		if (student_lesson_id == null) {
			if (other.student_lesson_id != null)
				return false;
		} else if (!student_lesson_id.equals(other.student_lesson_id))
			return false;
		return true;
	}

}
